package com.example.yang.mvp.m;


import com.example.yang.mvp.Bean;
import com.example.yang.mvp.Danli;
import com.example.yang.mvp.MyServer;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class M1 implements M2 {




    @Override
    public void getData( int page, final FinMain finMain) {


        Retrofit retrofit  = new Retrofit.Builder()
                .baseUrl(MyServer.URl)
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        Map<String, String> map = new HashMap<>();
        map.put("appKey","8b1263e0272f44738d757325c6cde702");
        map.put("category","星座");
        map.put("page",page+"");


        MyServer myServer = retrofit.create(MyServer.class);

        Call<Bean> list = myServer.getList(map);

        list.enqueue(new Callback<Bean>() {
            @Override
            public void onResponse(Call<Bean> call, Response<Bean> response) {
                finMain.showList(response.body().getRESULT().getNewsList());

            }

            @Override
            public void onFailure(Call<Bean> call, Throwable t) {

            }
        });


    }

}
